test: sweep the redundant producer casts, keep one as the back-compat net - #52
Merged
Conversation
… net PR #50 retyped computed's `from` callback and factory generators to the schema's `z.input`, making the `as z.infer<typeof X>` casts on their return values redundant. Sweeps them from the package's own spec and test-d files (docs and examples were already swept), leaving update() patch casts (PatchOf stays branded) and the one deliberate Legacy cast kept as a back-compat pin.
…ss return Review flagged the old title as inaccurate after the cast sweep: the test's own final line (a castless return) demonstrates the opposite of "must return brands".
There was a problem hiding this comment.
Pull request overview
This PR follows up on #50 by removing now-redundant as z.infer<...> casts that were only needed when producer callbacks (computed from functions and factory generators) were typed as branded outputs rather than schema inputs. It updates the package’s own spec/type-test files to match the new “producers need nothing” story while keeping a single intentional cast as a back-compat guard.
Changes:
- Removed producer-position
as z.infer<...>casts from computed field derivations across spec and type-test files. - Updated the type-test case name and body to reflect that computed return values are validated as schema input (no brand required).
- Kept one explicit producer cast in
entity.test-d.ts(Legacy) as the designated back-compat net.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/entity/src/nesting.spec.ts | Removes the redundant cast from a nested entity computed field derivation. |
| packages/entity/src/entity.test-d.ts | Sweeps producer casts, updates the computed typing test title/body, and preserves the single Legacy cast as back-compat coverage. |
| packages/entity/src/contract.spec.ts | Removes the redundant cast from a contract example’s computed field. |
| packages/entity/src/computed.spec.ts | Removes redundant casts from multiple computed derivations, including defect-path tests. |
| packages/entity/src/base.test-d.ts | Removes redundant casts from computed derivations in abstract-root/variant type tests. |
| packages/entity/src/base.spec.ts | Removes redundant casts from computed derivations in root/extend runtime specs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #50, which retyped
computed'sfromand factory generators as their schema'sz.inputand swept docs and examples. The package's own test files were left for follow-up — they held the onlyas z.infercasts remaining in the repo, and they contradicted the documented "producers need nothing" story.The rule applied
Delete iff producer position; everything else stays:
update(...)patch castsPatchOfis deliberately branded — those casts are still requiredas nevercastsEntity.Input/CreateInput/Patchhelper-type literalsz.infer-based (branded) and unaffected by #50Legacyguard15 producer casts deleted across 6 files. 19 casts survive, each classified.
The one deliberate producer cast left in the repo
entity.test-d.ts'sLegacyguard — a computedfromreturningas z.infer<typeof Upper>— is relabelled as the designated back-compat net: it pins that pre-#50 cast-carrying code still compiles (a branded return assigns to its schema's input). Its comment now says exactly that, so no future sweep takes it.Review also caught a title made stale by the sweep: "computed's function … must return brands" sat above a castless
return "X". Retitled to what the test now pins.Test plan
computed.ts/types.ts's signatures, and classified all 19 survivorstest/typecheck/test:types(no@ts-expect-errorwent unused),lint,format --check— greentypecheck/test/knip— greenNo changeset — test-internal.
🤖 Generated with Claude Code